﻿<?php
/* SVN FILE: $Id$ */
/**
 * Short description for file.
 *
 * This file is application-wide controller file. You can put all
 * application-wide controller-related methods here.
 *
 * PHP versions 4 and 5
 *
 * CakePHP(tm) :  Rapid Development Framework (http://www.cakephp.org)
 * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright     Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
 * @link          http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
 * @package       cake
 * @subpackage    cake.app
 * @since         CakePHP(tm) v 0.2.9
 * @version       $Revision$
 * @modifiedby    $LastChangedBy$
 * @lastmodified  $Date$
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 */
/**
 * Short description for class.
 *
 * Add your application-wide methods in the class below, your controllers
 * will inherit them.
 *
 * @package       cake
 * @subpackage    cake.app
 */
class AppController extends Controller {
	var $components = array('DebugKit.Toolbar', 'Auth');
	
	function beforeFilter(){
		$this->Auth->allow('add');
		$this->Auth->userModel = 'Usuario';
		$this->Auth->fields = array(
			'username' => 'email',
			'password' => 'senha'
			);
		$this->Auth->loginAction = array('controller' => 'usuarios', 'action' => 'login');
		
		/* Mostra mensagens de erro personalizadas */
		
		$this->Auth->authError = __('Você precisa registrar-se para ter acesso.', true);
		$this->Auth->loginError = __('Verifique o email e a senha digitada.', true);

		/* Testa se o usuário está logado */
		
		 if($this->Session->read('Auth.Usuario')) {
			$this->set('logado',$this->Session->read('Auth.Usuario'));
		}
	
	}
}
?>